package com.example.administrator.myapplication;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;

import com.bumptech.glide.Glide;

import java.util.LinkedHashMap;

import cn.jzvd.JZDataSource;
import cn.jzvd.Jzvd;
import cn.jzvd.JzvdStd;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        MyPlayer jzvdStd = (MyPlayer) findViewById(R.id.videoplayer);
        JzvdStd.SAVE_PROGRESS = false;
        JzvdStd.setMediaInterface(new JZMediaIjkplayer());
        LinkedHashMap map = new LinkedHashMap();
        map.put("高清", "http://192.168.0.110/videojs/oceans.mp4");
        map.put("标清", "http://jzvd.nathen.cn/c6e3dc12a1154626b3476d9bf3bd7266/6b56c5f0dc31428083757a45764763b0-5287d2089db37e62345123a1be272f8b.mp4");
        JZDataSource jzDataSource = new JZDataSource(map, "饺子不信");
        jzDataSource.currentUrlIndex = 1;

        jzDataSource.looping = true;
        jzvdStd.setUp(jzDataSource,Jzvd.SCREEN_WINDOW_NORMAL);
        Glide.with(this).load("http://192.168.0.110/videojs/oceans.png").into(jzvdStd.thumbImageView);
    }

    @Override
    public void onBackPressed() {
        if (Jzvd.backPress()) {
            return;
        }
        super.onBackPressed();
    }
    @Override
    protected void onPause() {
        super.onPause();
        Jzvd.releaseAllVideos();
    }

}
